utilities = {};

utilities.dom = {
	cssApply: function(argsObj) {
		//	argsObj: (object)
		//		element: (dom) the element it will be applied the style
		//		css: 
		//			(string) css class name > action: add / remove 
		//			(object css compliant) css style > action: add 
		//			(null) pass to remove all the attr style > action: remove
		//		action: (string) 'add' | 'remove'
		var $element = jQuery(argsObj.element);
		var propName;
		
		switch(argsObj.action) {
			case 'add':
				switch(typeof(argsObj.css)) {
					case 'object':
						$element.css(argsObj.css);
						break;
					case 'string':
						$element.addClass(argsObj.css);
						break;
				};
				break;
			case 'remove':
				switch(typeof(argsObj.css)) {
					case 'object':
						for (propName in argsObj.css) {
							$element.css(propName, '');
						};
						break;
					case 'string':
						$element.removeClass(argsObj.css);
						break;
				};
				break;
		};
	}
};

utilities.validators = {};

utilities.validators.notStrict = {
	isTypeOf: function(value, type) {
		if (typeof(value) == type) {
			return true;
		}
		else {
			return null;
		};
	},
	
	isObject: function(value) {
		return utilities.validators.notStrict.isTypeOf(value, 'object');
	},
	
	isString: function(value) {
		return utilities.validators.notStrict.isTypeOf(value, 'string');
	}
};

utilities.validators.strict = {
	isArray: function(value) {
		return (utilities.validators.strict.isObject(value))?
			value instanceof Array :
			false;
	},
	
	isBoolean: function(value) {
		return utilities.validators.strict.isTypeOf(value, 'boolean');
	},
	
	isDomElement: function(value) {
		if ((utilities.validators.strict.isObject(value)) &&
				(utilities.validators.strict.isNotNull(value)) &&
				('nodeType' in value)) {
			return true;
		}
		else {
			return false;
		};
	},
	
	isFunction: function(value) {
		return utilities.validators.strict.isTypeOf(value, 'function');
	},
	
	isNumber: function(value) {
		return utilities.validators.strict.isTypeOf(value, 'number');;
	},
	
	isNotNull: function(value) {
		return value != null;
	},
	
	isNotUndefined: function(value) {
		return !utilities.validators.strict.isTypeOf(value, 'undefined');
	},
	
	isObject: function(value) {
		return utilities.validators.strict.isTypeOf(value, 'object');
	},
	
	isString: function(value) {
		return utilities.validators.strict.isTypeOf(value, 'string');
	},
	
	isTypeOf: function(value, type) {
		if (typeof(value) == type) {
			return true;
		}
		else {
			return false;
		};
	},
	
	isUndefined: function(value) {
		return utilities.validators.strict.isTypeOf(value, 'undefined');
	}
};

utilities.filters = {};

utilities.filters.notStrict = {
	nullFilter: function(value) {
		return (utilities.validators.strict.isNotNull(value))?
			null :
			void(0);
	},
	
	undefinedFilter: function(value) {
		return (utilities.validators.strict.isNotUndefined(value))?
			null :
			void(0);
	}
};

utilities.filters.strict = {
	notNullFilter: function(value) {
		return (utilities.validators.strict.isNotNull(value))?
			null :
			false;
	},
	
	notUndefinedFilter: function(value) {
		return (utilities.validators.strict.isNotUndefined(value))?
			null :
			false;
	},
	
	nullFilter: function(value) {
		return (utilities.validators.strict.isNotNull(value))?
			false :
			null;
	},
	
	undefinedFilter: function(value) {
		return (utilities.validators.strict.isNotUndefined(value))?
			false :
			void(0);
	}
};
